package com.bjkcst.baselib.utils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.URL;

/**
 * usb插拔广播
 * 内置拷贝文件操作
 */
public class UsbBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent == null || context == null) {
            return;
        }
        Log.e("chenyan", "onReceive");
        String action = intent.getAction();
        if (action.equals(Intent.ACTION_MEDIA_EJECT)) {
            Log.e("chenyan", "ACTION_MEDIA_EJECT");
            UsbManger.getInstance().usbRemove();
        } else if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
            Log.e("chenyan", "ACTION_MEDIA_MOUNTED");
            //usb设备挂载
            Uri uri = intent.getData();
            UsbManger.getInstance().usbMount(uri);
        }
    }



}
